﻿@using X.PagedList;
@using X.PagedList.Mvc.Core;
@using X.PagedList.Mvc.Common;
@using FwProject.Distribution.Dto
@model ReceivableNewSummaryDto
@{
    Layout = null;
    decimal SumTotalPrice = 0m;
    decimal SumActualPrice = 0m;
    decimal SumDiscountPrice = 0m;
    decimal SumReceivedDiscount = 0m;
    decimal SumTotalDiscount = 0m;

    decimal SumReceivedPrice = 0m;
    decimal SumTaskNotBackAmount = 0m;
    int i = 0;
    if (Model.PageList.Count > 0)
    {
        if (Model.PageList.PageNumber != 1)
        {

            i = (Model.PageList.PageNumber - 1) * Model.PageList.PageSize;
        }
    }
}
<div id="table_print" style="max-height:600px;overflow-y:scroll;">
    @if (Model.PageList.Count == 0)
    {
        <h4>暂无数据</h4>
    }
    else
    {
        <table class="table table-bordered table-hover table-rowselected">
            <thead>
                <tr>
                    <th style="width:45px">序号</th>
                    <th>状态</th>
                    <th>应收类型</th>
                    <th>餐厅</th>
                    @*<th>配送司机</th>*@
                    <th>开单日期</th>
                    <th>单号</th>
                    <th>配送日期</th>
                    <th>整单金额（￥）</th>
                    <th>应收金额（￥）</th>
                    <th>已收金额（￥）</th>
                    <th>未收金额（￥）</th>
                    <th>制单优惠（￥）</th>
                    <th>收款优惠（￥）</th>
                    <th>总优惠（￥）</th>
                    <th>折扣率</th>
                </tr>
            </thead>
            <tbody>
                @foreach (var item in Model.PageList)
                {
                    i++;
                    <tr>
                        <td>@i</td>
                        <td>@item.RestaurantPayStatus</td>
                        <td>@item.BalanceWayEnum</td>
                        <td>@item.RestaurantName</td>
                        @*<td>@item.DriverName</td>*@
                        <td>@item.CreationTime.ToString("yyyy-MM-dd")</td>
                        <td><a href="javascript:top.window.openTab(1778,'收据[@item.CreationNumber]','/Receipt/SettlementDetails?id=@item.Id')">@item.CreationNumber</a></td>
                        <td>@item.DeliveryDate</td>
                        <td>@item.Totalprice</td>
                        <td>@item.Actualprice</td>
                        <td>@item.ReceivedPrice</td>
                        <td>@item.TaskNotBackAmount</td>
                        <td>@item.Discountprice</td>
                        <td>@item.ReceivedDiscount</td>
                        <td>@item.TotalDiscount</td>
                        <td>@item.DiscountRate</td>
                    </tr>
                    SumActualPrice += item.Actualprice;
                    SumTotalPrice += item.Totalprice;
                    SumDiscountPrice += item.Discountprice;
                    SumReceivedDiscount += item.ReceivedDiscount;
                    SumTotalDiscount += item.TotalDiscount;

                    SumReceivedPrice += item.ReceivedPrice;
                    SumTaskNotBackAmount += item.TaskNotBackAmount;
                }
                @*<tr class="footer">
                        <td colspan="2" style="color:red;text-align:center">该页小计</td>
                        <td colspan="5"></td>
                        <td style="color:red">@SumTotalPrice</td>
                        <td style="color:red">@SumActualPrice</td>
                        <td style="color:red">@SumReceivedPrice</td>
                        <td style="color:red">@SumTaskNotBackAmount</td>

                        <td style="color:red">@SumDiscountPrice</td>
                        <td style="color:red">@SumReceivedDiscount</td>
                        <td style="color:red">@SumTotalDiscount</td>
                        <td style="color:red">@((Convert.ToDouble(SumTotalDiscount) / Convert.ToDouble(SumTotalPrice)).ToString("0.00%"))</td>
                    </tr>*@
                <tr class="footer" style="background-color:darkgray">
                    <td colspan="2" style="color:red;text-align:center">总合计</td>
                    <td colspan="5"></td>
                    <td style="color:red">@Model.SumTotalPrice</td>
                    <td style="color:red">@Model.SumActualPrice</td>
                    <td style="color:red">@Model.SumReceivedPrice</td>
                    <td style="color:red">@Model.SumTaskNotBackAmount</td>

                    <td style="color:red">@Model.SumDiscountPrice</td>
                    <td style="color:red">@Model.SumReceivedDiscount</td>
                    <td style="color:red">@Model.SumTotalDiscount</td>
                    <td style="color:red">@((Convert.ToDouble(Model.SumTotalDiscount) / Convert.ToDouble(Model.SumTotalPrice)).ToString("0.00%"))</td>
                </tr>
            </tbody>
        </table>
    }
</div>
<div class="row pagedinfo">
    <div class="col-sm-5">
        @*共 @Model.PageList.TotalItemCount 条，@Model.PageList.PageSize 条/页 当前第 @Model.PageList.PageNumber/@Model.PageList.PageCount 页*@
        共 @Model.PageList.TotalItemCount 条，
        <select class="form-control" id="pageSize" style="width:70px;display:initial">
            @for (int z = 10; z < 100; z = z + 10)
            {
                if (z == Model.PageList.PageSize)
                {
                    <option selected value="@z">@z</option>
                }
                else
                {
                    <option value="@z">@z</option>
                }
            }
        </select> &nbsp;条/页 当前第 @Model.PageList.PageNumber/@Model.PageList.PageCount 页
    </div>
    <div class="col-sm-7">
        <input type="hidden" id="pageurl" value="&Name=@(Context.Request.Query["Name"])&PlatesNumber=@(Context.Request.Query["PlatesNumber"])&beginTime=@(Context.Request.Query["beginTime"])&endTime=@(Context.Request.Query["endTime"])" />
        @Html.PagedListPager(Model.PageList, page => Url.Action("Index", new { pageIdx = page, size = Context.Request.Query["size"], Name = Context.Request.Query["Name"], PlatesNumber = Context.Request.Query["PlatesNumber"], beginTime = Context.Request.Query["beginTime"], endTime = Context.Request.Query["endTime"] }), PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(new AjaxOptions() { AllowCache = false, HttpMethod = "Get", UpdateTargetId = "data_list", OnSuccess = "AjaxSuccessCallback", OnBegin = "AjaxBegin" }))
    </div>
</div>

